/*
               File: PrcCadastrarRespostaUsuario
        Description: Prc Cadastrar Resposta Usuario
             Author: GeneXus C# Generator version 10_2_5-78484
       Generated on: 6/6/2014 9:52:44.6
       Program type: Callable routine
          Main DBMS: sqlserver
*/
using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using System.Data;
using System.Data.SqlClient;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.Procedure;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Threading;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
   public class prccadastrarrespostausuario : GXProcedure
   {
      public prccadastrarrespostausuario( )
      {
         context = new GxContext(  );
         DataStoreUtil.LoadDataStores( context);
         dsDefault = context.GetDataStore("Default");
         IsMain = true;
         context.SetDefaultTheme("GeneXusXEv2");
      }

      public prccadastrarrespostausuario( IGxContext context )
      {
         this.context = context;
         IsMain = false;
         dsDefault = context.GetDataStore("Default");
      }

      public void release( )
      {
      }

      public void execute( ref long aP0_UserId ,
                           ref short aP1_OpcoesEnqueteId ,
                           ref short aP2_EnqueteId )
      {
         this.AV10UserId = aP0_UserId;
         this.AV9OpcoesEnqueteId = aP1_OpcoesEnqueteId;
         this.AV8EnqueteId = aP2_EnqueteId;
         initialize();
         executePrivate();
         aP0_UserId=this.AV10UserId;
         aP1_OpcoesEnqueteId=this.AV9OpcoesEnqueteId;
         aP2_EnqueteId=this.AV8EnqueteId;
      }

      public short executeUdp( ref long aP0_UserId ,
                               ref short aP1_OpcoesEnqueteId )
      {
         this.AV10UserId = aP0_UserId;
         this.AV9OpcoesEnqueteId = aP1_OpcoesEnqueteId;
         this.AV8EnqueteId = aP2_EnqueteId;
         initialize();
         executePrivate();
         aP0_UserId=this.AV10UserId;
         aP1_OpcoesEnqueteId=this.AV9OpcoesEnqueteId;
         aP2_EnqueteId=this.AV8EnqueteId;
         return AV8EnqueteId ;
      }

      public void executeSubmit( ref long aP0_UserId ,
                                 ref short aP1_OpcoesEnqueteId ,
                                 ref short aP2_EnqueteId )
      {
         prccadastrarrespostausuario objprccadastrarrespostausuario;
         objprccadastrarrespostausuario = new prccadastrarrespostausuario();
         objprccadastrarrespostausuario.AV10UserId = aP0_UserId;
         objprccadastrarrespostausuario.AV9OpcoesEnqueteId = aP1_OpcoesEnqueteId;
         objprccadastrarrespostausuario.AV8EnqueteId = aP2_EnqueteId;
         objprccadastrarrespostausuario.context.SetSubmitInitialConfig(context);
         objprccadastrarrespostausuario.initialize();
         ThreadPool.QueueUserWorkItem( new WaitCallback( executePrivateCatch ),objprccadastrarrespostausuario);
         aP0_UserId=this.AV10UserId;
         aP1_OpcoesEnqueteId=this.AV9OpcoesEnqueteId;
         aP2_EnqueteId=this.AV8EnqueteId;
      }

      void executePrivateCatch( object stateInfo )
      {
         try
         {
            ((prccadastrarrespostausuario)stateInfo).executePrivate();
         }
         catch ( Exception e )
         {
            GXUtil.SaveToEventLog( "Design", e);
            throw e ;
         }
      }

      void executePrivate( )
      {
         /* GeneXus formulas */
         /* Output device settings */
         /*
            INSERT RECORD ON TABLE TBLRespostaUsuario

         */
         A56RespostaUsuarioUserId = AV10UserId;
         A57RespostaUsuarioEnqueteId = AV8EnqueteId;
         A58RespostaUsuarioOpcoesEnqueteId = AV9OpcoesEnqueteId;
         /* Using cursor P000G2 */
         pr_default.execute(0, new Object[] {A56RespostaUsuarioUserId, A57RespostaUsuarioEnqueteId, A58RespostaUsuarioOpcoesEnqueteId});
         pr_default.close(0);
         dsDefault.SmartCacheProvider.SetUpdated("TBLRespostaUsuario") ;
         if ( (pr_default.getStatus(0) == 1) )
         {
            context.Gx_err = 1;
            Gx_emsg = (String)(context.GetMessage( "GXM_noupdate", ""));
         }
         else
         {
            context.Gx_err = 0;
            Gx_emsg = "";
         }
         /* End Insert */
         this.cleanup();
      }

      public void cleanup( )
      {
         context.CommitDataStores("PrcCadastrarRespostaUsuario");
         CloseOpenCursors();
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
         exitApplication();
      }

      protected void CloseOpenCursors( )
      {
      }

      public override void initialize( )
      {
         Gx_emsg = "";
         pr_default = new DataStoreProvider(context, new GeneXus.Programs.prccadastrarrespostausuario__default(),
            new Object[][] {
                new Object[] {
               }
            }
         );
         /* GeneXus formulas. */
         context.Gx_err = 0;
      }

      private short AV9OpcoesEnqueteId ;
      private short AV8EnqueteId ;
      private int GX_INS9 ;
      private long AV10UserId ;
      private long A56RespostaUsuarioUserId ;
      private long A57RespostaUsuarioEnqueteId ;
      private long A58RespostaUsuarioOpcoesEnqueteId ;
      private String Gx_emsg ;
      private IGxDataStore dsDefault ;
      private long aP0_UserId ;
      private short aP1_OpcoesEnqueteId ;
      private short aP2_EnqueteId ;
      private IDataStoreProvider pr_default ;
   }

   public class prccadastrarrespostausuario__default : DataStoreHelperBase, IDataStoreHelper
   {
      public ICursor[] getCursors( )
      {
         cursorDefinitions();
         return new Cursor[] {
          new UpdateCursor(def[0])
       };
    }

    private static CursorDef[] def;
    private void cursorDefinitions( )
    {
       if ( def == null )
       {
          Object[] prmP000G2 ;
          prmP000G2 = new Object[] {
          new Object[] {"@RespostaUsuarioUserId",SqlDbType.Decimal,15,0} ,
          new Object[] {"@RespostaUsuarioEnqueteId",SqlDbType.Decimal,15,0} ,
          new Object[] {"@RespostaUsuarioOpcoesEnqueteId",SqlDbType.Decimal,15,0}
          } ;
          def= new CursorDef[] {
              new CursorDef("P000G2", "INSERT INTO [TBLRespostaUsuario] ([RespostaUsuarioUserId], [RespostaUsuarioEnqueteId], [RespostaUsuarioOpcoesEnqueteId]) VALUES (@RespostaUsuarioUserId, @RespostaUsuarioEnqueteId, @RespostaUsuarioOpcoesEnqueteId)", GxErrorMask.GX_NOMASK,prmP000G2)
          };
       }
    }

    public void getResults( int cursor ,
                            IFieldGetter rslt ,
                            Object[] buf )
    {
       switch ( cursor )
       {
       }
    }

    public void setParameters( int cursor ,
                               IFieldSetter stmt ,
                               Object[] parms )
    {
       switch ( cursor )
       {
             case 0 :
                stmt.SetParameter(1, (long)parms[0]);
                stmt.SetParameter(2, (long)parms[1]);
                stmt.SetParameter(3, (long)parms[2]);
                break;
       }
    }

 }

}
